<template>
	<view class="container">
		<t-empty v-if="orderList.length == 0" tipText="空空如也~"></t-empty>
		<scroll-view class="box-list">
			<view class="card-box" v-for="(item,index) in orderList" :key="index">
				<view class="card-box-head u-flex u-col-center">
					<text class="shop-name">{{item.goods_name}}</text>
					<text class="order-status">{{item.status_text}}</text>
				</view>
				<view class="card-box-body card-box-body-cloumn">
					<view class="left-img">
						<image mode="aspectFill" :src="$IMG_URL+item.goods_image"></image>
					</view>
					<view class="t-flex-col right-info">
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<image mode="aspectFill" :src="$IMG_URL+'/imgs/freelunch/mt-icon.png'">
								</image>
							</view>
							<view class="right-info-dec">满{{item.normal_rich_fee}}返{{item.normal_rich_desc}}</view>
						</view>
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<uni-icons style="margin-right: 10rpx;" type="calendar" size="22">
								</uni-icons>
							</view>
							<view class="right-info-box-dec">
								{{$util.date("Y/m/d",parseInt(item.goods.start_time))}}~{{$util.date("Y/m/d",parseInt(item.goods.end_time))}}
							<!-- {{item.goods.start_time_text}}~{{item.goods.end_time_text}} -->
							</view>
						</view>
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<uni-icons style="margin-right: 10rpx;" type="notification" size="22">
								</uni-icons>
							</view>
							<!-- <view class="right-info-box-dec">订单实付：未识别</view> -->
							<view class="right-info-box-dec">报名时间：{{$util.date("Y/m/d H:i",item.createtime)}}</view>
						</view>
					</view>
				</view>
				<view class="t-flex card-box-footer u-flex u-col-center">
					<view class="t-flex footer-status">
						<view class="footer-status-view">
							订单号：<text style="color: #666;" class="footer-status-text">{{item.order_sn}}</text>
						</view>

					</view>
					<view class="t-flex footer-btn">
						<button class="footer-btn-edit"
							@tap.stop="jump('/pages/order/order-detail?id='+item.id)">查看截图</button>
					</view>
				</view>
			</view>
		</scroll-view>
		<block v-if="selectId && selectId > 0">
			<t-menu></t-menu>
		</block>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				goods_id: 0,
				status: 0,
				requestIng: false,
				orderList: [],
				page: 1,
				// currentStatus: 0,
			}
		},
		computed: {
			...mapGetters(['userInfo']),
			/* status() {
				console.log('status')
				if (this.currentShopIndex && this.currentShopIndex > -1 && this.navBarShopList && this.navBarShopList
					?.length > 0) {
					this.getOrderList(1)
				}
				return this.currentStatus;
			}, */
		},
		watch: {
			/* currentStatus(newVal, oldVal) {
				console.log('watch-currentStatus')
				this.getOrderList(1)
			} */
		},
		onLoad(e) {
			this.goods_id = e.id;
			this.status = e.status;
		},
		onShow() {
			console.log('onShow')
			this.getOrderList()
			// this.$store.dispatch('getOrderVerifyNum');
		},
		methods: {
			jump(url) {
				this.$util.jump(url)
			},
			/* selectShop(e) {
				this.$store.commit('currentShopIndex', e.detail.value)
				this.getOrderList(1)
			},
			async init() {
				console.log('init')
				this.currentStatus = 0;
				this.getOrderList(1)
			},
			selectTab(index) {
				this.currentStatus = index
			}, */
			async getOrderList() {
				let that = this;
				let requestData = {
					page: that.page,
					status: that.status,
					goods_id: that.goods_id
				};
				console.log('getOrderList',requestData)
				that.$util.loading('加载中');
				// return new Promise((resolve, reject) => {
				that.$http('order.list', requestData).then(async res => {
						console.log('订单列表', res)
						that.requestIng = false
						uni.hideLoading()
						if (res.code === 1) {
							if (requestData.page == 1) {
								that.orderList = res.data.list
							} else {
								that.orderList = that.orderList.concat(res.data.list)
							}
							if (res.data?.length > 0) {
								console.log('页码增加')
								that.page = requestData.page + 1
							}
							// resolve(res.data.list);
						} else {
							// resolve(false);
						}
					})
					.catch(async err => {
						that.requestIng = false
						uni.hideLoading()
						// resolve(false);
					})
				// });
			},
		},
		onPullDownRefresh() {
			console.log('onPullDownRefresh')
			setTimeout(function() {
				uni.stopPullDownRefresh()
				console.log('stopPullDownRefresh')
			}, 1000)
		},
		onReachBottom() {
			console.log('onReachBottom');
			!this.requestIng && (this.requestIng = true, this.getOrderList(this.page))
		},
	}
</script>

<style lang="scss">
	@import '../../common/style/city.css';

	.t-flex {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.t-flex-col {
		@extend .t-flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
	}

	.container {
		.box-list {
			margin: 0;
		}

		.card-box {
			width: 94%;
			min-height: 100rpx;
			margin: 30rpx 3%;
			padding: 30rpx 0;
			background: #FFF;
			background-size: 100% 100%;
			box-shadow: 0px 7rpx 11rpx 2rpx rgba(213, 175, 97, 0.34);
			border-radius: 30rpx;
			overflow: hidden;
			position: relative;
			// z-index: 810;


			&-head,
			.card-box-footer {
				color: #000;
				font-size: 30rpx;
				display: flex;
				justify-content: space-between;
				width: 94%;
				margin-left: 3%;
				height: 50rpx;
				align-items: center;
			}

			.shop-name,
			.order-status {
				font-size: 30rpx;
				font-weight: 700;
			}

			.order-status {
				color: #ff9000;
			}

			&-body {
				width: 94%;
				margin: 30rpx 3%;
				display: flex;
				align-items: center;

				.left-img {
					width: 140rpx;
					height: 140rpx;
					border-radius: 20rpx;
					margin-right: 20rpx;
				}

				.right-info {
					font-size: 26rpx;
					color: #999;

					&-box {
						justify-content: flex-start;

						&-icon {
							@extend .t-flex;
							justify-content: center;
							height: 60rpx;
							width: 60rpx;
							margin-right: 10rpx;

							image {
								width: 38rpx;
								height: 38rpx;
							}
						}

						.right-info-box-num {
							font-size: 28rpx;
							color: #333;
							font-weight: 600;
							margin-right: 10rpx;

							text {
								color: #FF9000;
							}
						}

						.right-info-dec {
							color: #666;
						}
					}
				}
			}

			.card-box-footer {
				font-size: 28rpx;
				color: #666;

				.footer-status {
					.footer-status-view {
						@extend .t-flex;
						justify-content: flex-start;
						margin-right: 10rpx;

						.footer-status-text {
							color: #ff9000;
						}
					}
				}

				.footer-btn {
					button {
						height: 60rp;
						min-width: 140rpx;
						margin: 0 5rpx;
						border: none;
						background: #ff9000;
						border-radius: 80rpx;
						color: #fff;
						font-size: 26rpx;
					}

					.footer-btn-edit {
						background: #fff;
						border: 1px solid #ff9000;
						color: #ff9000;
					}
				}
			}
		}


	}

	image {
		width: 140rpx;
		height: 140rpx;
		border-radius: 10px;
	}
</style>
